package com.zkyc.framework.common.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zkyc.framework.common.pojo.Center;
import com.zkyc.framework.common.pojo.Organization;
import org.apache.ibatis.annotations.*;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.mapping.FetchType;

import java.util.List;

/**
 * (Organization)表数据库访问层
 *
 * @author libingchuan
 * @since 2022-05-25 16:06:10
 */
@Mapper
public interface OrganizationMapper extends BaseMapper<Organization> {

    @Select(value = {"<script>" +
            "select * from web_organization where is_deleted != 1 " +
            " <if test='userId!=null and userId !=\"\" '>" +
            " and operate_user_id = #{userId} " +
            " </if>" +
            "</script>"
    })
    @Results(id = "organizationMap", value = {
            @Result(id = true, property = "id", column = "id"),
            @Result(property = "children", column = "id",
                    many = @Many(select = "com.zkyc.framework.common.mapper.CenterMapper.findCenterByOid", fetchType = FetchType.DEFAULT))
    })
    List<Organization> findAllOrganization(String userId);

    //void selectList(QueryWrapper<Center> queryWrapper);
}

